//router文件夹下新建index.js文件
import {
	createRouter,
	createWebHistory
} from 'vue-router'

import NProgress from 'nprogress'
import 'nprogress/nprogress.css'
//注册路由
const routes = [{
	path: '/',
	name: 'home',
	component: () => import('@/views/home')
},{
	path: '/page2',
	name: 'page2',
	component: () => import('@/views/page2')
},{
	path: '/page3',
	name: 'page3',
	component: () => import('@/views/page3')
},{
	path: '/page4',
	name: 'page4',
	component: () => import('@/views/page4')
}];
const router = createRouter({
	history: createWebHistory(),
	routes
});

//全局守卫
router.beforeEach((to, from, next) => {
	NProgress.start()
	next()
})

router.beforeResolve((to, from, next) => {
	next()
})

router.afterEach((to, from) => {
	NProgress.done()
})

export default router;